package biz.ezcom.design.pattern.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理处理类 
 */
public class ProxyHandler implements InvocationHandler{
	private Object target;
	
	public ProxyHandler(Object target) {
		this.target = target;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println(method.getName() + "() before");
		Object result = method.invoke(target, args);//目标方法调用
		System.out.println(method.getName() + "() after");
		return result;
	}
	
}
